//
//  UICarouseView.h
//  mobile
//
//  Created by Jocer on 2018/4/21.
//  Copyright © 2018年 azazie. All rights reserved.
//

#import <UIKit/UIKit.h>

@class UICarouselView;

typedef void(^ClickBlock)(NSInteger index);

typedef void(^CustomViewRenderer)(__kindof UIView *view, id data ,NSInteger idx);

typedef NS_ENUM(NSInteger, PageControlPosition) {
    PositionDefault = 0,
    PositionHide,
    PositionTopCenter,
    PositionBottomLeft,
    PositionBottomCenter = PositionDefault,
    PositionBottomRight
};

typedef NS_ENUM(NSInteger, GifPlayMode) {
    GifPlayModeAlways,
    GifPlayModeNever,
    GifPlayModePauseWhenScroll
};

typedef NS_ENUM(NSInteger, ChangeMode) {
    ChangeModeDefault,
    ChangeModeFade
};

@protocol UICarouselViewDelegate <NSObject>
@optional
- (void)carouselView:(UICarouselView *)carouselView clickImageAtIndex:(NSInteger)index;
@end

@protocol UICarouselViewCustomViewDelegate <UICarouselViewDelegate>

@optional
- (void)carouselView:(UICarouselView *)carouselView rederringCustomView:(UIView *)view data:(id)data;
@end

UIImage *gifImageNamed(NSString *imageName);

@interface UICarouselView : UIView

#pragma mark - Properties

@property (nonatomic, assign) ChangeMode changeMode;

@property (nonatomic, assign) UIViewContentMode contentMode;

@property (nonatomic, assign) PageControlPosition pagePosition;

@property (nonatomic, assign) CGPoint pageOffset;

@property (nonatomic, strong) UIImage *placeholderImage; //nil by default

@property (nonatomic, assign) BOOL showLoadingIndicator; //NO by default

@property (nonatomic, strong) NSArray *contentsArray;

@property (nonatomic, assign) NSTimeInterval time;

@property (nonatomic, assign) BOOL autoCache;

@property (nonatomic, assign) BOOL disabledTimer; //禁止自动轮播

@property (nonatomic, assign) BOOL disabledCarousel; //禁止边界轮播

@property (nonatomic, assign) GifPlayMode gifPlayMode;

@property (nonatomic, copy) ClickBlock clickBlock;

@property (nonatomic, copy) CustomViewRenderer renderer;

@property (nonatomic, weak) id<UICarouselViewDelegate> delegate;

@property (nonatomic, weak) id<UICarouselViewCustomViewDelegate> rendererDelegate NS_UNAVAILABLE;


#pragma mark - Methods

- (void)startTimer;

- (void)stopTimer;

- (void)setPageImage:(UIImage *)image andCurrentPageImage:(UIImage *)currentImage;

- (void)setPageColor:(UIColor *)color andCurrentPageColor:(UIColor *)currentColor;

- (void)registerCustomViewClass:(Class)cls; //自定义的轮播视图使用手动布局

@end
